<?php
/**
 *问答社区发现页控制器
 */
class Commwapdiscover extends Base_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('commwap_model');
    }
    /**
     *获取banner和subject信息
     */
    public function index()
    {
        $banner = $this->commwap_model->getBanner();
        $subject = $this->commwap_model->getSubject();
        $this->success(array('banner'=>$banner,'subject'=>$subject));
    }
    /**
     *获取热门问题推荐列表
     */
    public function getQuestion()
    {
        $post = $this->input->post();

        if (!isset($post['pagesize'])||!is_numeric($post['pagesize'])) $this->error('error: lack pagesize');
        else $limit = (int)$post['pagesize'];

        if (isset($post['page'])&&is_numeric($post['page'])) $offset = ((int)$post['page']-1)*$limit;
        else $offset = 0;

        $res = $this->commwap_model->getQuestionWithUser($offset,$limit);
        $this->success($res);
    }
}